﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using ATSIDAL;
using ATSModel;
using ATSModel.T_ReportInfo;

namespace ATSDAL
{
    public class PIMRepairReport : BaseRepository<PIMRepairInfo>, IPIMRepair
    {
        private const string PARM_TESTITEM_STRATDATE = "@starttime";
        private const string PARM_TESTITEM_ENDDATE = "@stoptime"; 

        public IList<PIMRepairInfo> LoadEntities()
        {
            return null;
        }

        public PIMRepairInfo LoadEntity<T1>(T1 Id)
        {
            return null;
        }

        //交调日返修报表根据时间 
        public IList<PIMRepairInfo> GetPIMRepairInfo(DateTime dt1, DateTime dt2)
        {
            SqlParameter[] testItemParms = GetSNTParameters();
            testItemParms[0].Value = dt1.ToShortDateString();
            testItemParms[1].Value = dt2.ToShortDateString();
            return ExcuteSqlToGetEntities("PIMRepairT_Report", testItemParms);
        }

        //交调日返修报表 
        public IList<PIMRepairInfo> GetPIMRepairAllInfo()
        {
            return ExcuteSqlToGetEntities("PIMRepairNum_Report");
        }

        #region 参数部分
        private static SqlParameter[] GetSNTParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_TESTITEM_STRATDATE, SqlDbType.DateTime, 8),
					new SqlParameter(PARM_TESTITEM_ENDDATE, SqlDbType.DateTime, 8)                
                };
            return parms;
        }
        #endregion

        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------
         

        public override PIMRepairInfo GetEntityRecord(SqlDataReader rdr)
        {
            PIMRepairInfo pro = new PIMRepairInfo
            {
                RecordDate = rdr.GetValue(0).ToString(),
                MOID = rdr.GetValue(1).ToString(),
                ProductTypeID = rdr.GetValue(2).ToString(),
                ProductTypeName = rdr.GetValue(3).ToString(),
                TestCoutOne = rdr.GetValue(4).ToString(),
                PassAmountOne = rdr.GetValue(5).ToString(),
                PassRateOne = rdr.GetValue(6).ToString(),
                RepairNumOne = rdr.GetValue(7).ToString(),

                TestCoutTwo = rdr.GetValue(8).ToString(),
                PassAmountTwo = rdr.GetValue(9).ToString(),
                PassRateTwo = rdr.GetValue(10).ToString(),
                RepairNumTwo = rdr.GetValue(11).ToString(),

                TestCoutThree = rdr.GetValue(12).ToString(),
                PassAmountThree = rdr.GetValue(13).ToString(),
                PassRateThree = rdr.GetValue(14).ToString(),
                RepairNumThree = rdr.GetValue(15).ToString(),
            };
            return pro;
        }
        #endregion
    }
}

